<template>
  <el-dialog title="仓库盘点" width="60%" :before-close="dialogClose" :visible.sync="show">
    <!--<el-form ref="form" :model="item" label-width="80px">
        <el-form-item label="分类名称">
          <el-input v-model="item.name" class="select_input"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="add">确 定</el-button>
          <el-button @click="dialogClose">取 消</el-button>
        </el-form-item>
      </el-form>-->
       <el-table :data="list.slice((currentPage-1)*pagesize,currentPage*pagesize)" style="width: 100%"
        row-key="id" border lazy>
      <el-table-column prop="id" label="产品ID" align="center" width="80"></el-table-column>
      <el-table-column prop="name" label="产品名称" align="center" width="200"></el-table-column>
      <el-table-column prop="lable" align="center" label="产品单位" width="100"></el-table-column>
      <el-table-column prop="price" align="center" label="产品价格" width="130"></el-table-column>
      <el-table-column prop="num" align="center" label="产品库存" width="80"></el-table-column>
      <el-table-column prop="real_num" align="center" label="实际库存" width="120">
        <template slot-scope="scope">
            <el-input v-model="scope.row.real_num" placeholder="实际库存"></el-input>
          </template>
      </el-table-column>
    </el-table>
    <el-pagination
      class="fen"
      background
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-size="pagesize"
      :page-sizes="[5, 10, 20, 50]"      
      layout="total, sizes, prev, pager, next, jumper"
      :total="list.length">
      </el-pagination>
      <div style="text-align:center;margin-top:20px;">
          <el-button type="primary" @click="add">确 定</el-button>
          <el-button @click="dialogClose">取 消</el-button>
      </div>
  </el-dialog>
</template>
 
<script>
export default {
  name: 'goodsCheck',
  props:['show','list'],
  data() {
    return {
        currentPage:1, //初始页
        pagesize:10, //每页的数据
        show_page:true,
        nowpage:1,
        maxpage:10,
    }
  },
  created: function() {
  },
  methods: {
    dialogClose:function(){
      //this.show = false
      this.$emit("func",{'key':'goodsCheckShow','type':0})
    },
    handleSizeChange: function (size) {
        this.pagesize = size;
    },
    handleCurrentChange: function(currentPage){
      this.currentPage = currentPage;
    },
    changeLeft($event){
        $event.currentTarget.className="active";
    },
    removeLeft($event){
        $event.currentTarget.className ="tdclass";
    },
    add:function(){
      var that = this
      this.$post('check/add',this.list).then((res) => {
          if(res.code == 1){
            that.$message.success(res.msg);
          }else{
            that.$message.error(res.msg);
          }
          that.$emit("func",{'key':'goodsCheckShow','type':1})
      })
    }
  }
}
</script>